// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   change_delete_details.java

package logistics.product_providers;

import include.nseer_cookie.GetWorkflow;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;

public class change_delete_details extends HttpServlet
{

	public change_delete_details()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			nseer_db_backup1 logistics_db = new nseer_db_backup1(dbApplication);
			if (logistics_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String id = request.getParameter("id");
				String product_logistics_recommend_ID = request.getParameter("product_logistics_recommend_ID");
				try
				{
					String sql = (new StringBuilder("delete from logistics_product_providers_recommend_details where id='")).append(id).append("'").toString();
					logistics_db.executeUpdate(sql);
					sql = (new StringBuilder("update logistics_product_providers_recommend set change_tag='1' where product_logistics_recommend_ID='")).append(product_logistics_recommend_ID).append("'").toString();
					logistics_db.executeUpdate(sql);
					List rsList = GetWorkflow.getList(logistics_db, "logistics_config_workflow", "03");
					String elem[] = new String[3];
					if (rsList.size() == 0)
					{
						sql = (new StringBuilder("update logistics_product_providers_recommend set check_tag='1' where product_logistics_recommend_ID='")).append(product_logistics_recommend_ID).append("'").toString();
						logistics_db.executeUpdate(sql);
					} else
					{
						sql = (new StringBuilder("delete from logistics_workflow where object_ID='")).append(product_logistics_recommend_ID).append("'").toString();
						logistics_db.executeUpdate(sql);
						sql = (new StringBuilder("update logistics_product_providers_recommend set check_tag='0' where product_logistics_recommend_ID='")).append(product_logistics_recommend_ID).append("'").toString();
						logistics_db.executeUpdate(sql);
						for (Iterator ite = rsList.iterator(); ite.hasNext(); logistics_db.executeUpdate(sql))
						{
							elem = (String[])ite.next();
							sql = (new StringBuilder("insert into logistics_workflow(config_id,object_ID,describe1,describe2) values ('")).append(elem[0]).append("','").append(product_logistics_recommend_ID).append("','").append(elem[1]).append("','").append(elem[2]).append("')").toString();
						}

					}
				}
				catch (Exception ex)
				{
					ex.printStackTrace();
				}
				response.sendRedirect((new StringBuilder("logistics/product_providers/change.jsp?product_logistics_recommend_ID=")).append(product_logistics_recommend_ID).toString());
				logistics_db.commit();
				logistics_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
